﻿using System;
using System.Collections.Generic;

namespace Yawf.Data {
	public interface IPersister {
		/// <summary>
		///		Gets one persistent object from database or other persistent source 
		/// </summary>
		/// <param name="query">Query to use, could be a query(NHibernate) or a statement name(IBatis)</param>
		/// <param name="parameters">The parameters to use</param>
		/// <returns>The persistent object if found</returns>
		T FindOne<T>(String query,Object parameters);

		/// <summary>
		///		Gets a list of persistent objects from database or other persistent source 
		/// </summary>
		/// <param name="query">Query to use, could be a query(NHibernate) or a statement name(IBatis)</param>
		/// <param name="parameters">The parameters to use</param>
		/// <returns>A list of found object</returns>
		IList<T> FindList<T>(String query,Object parameters);

		/// <summary>
		/// Gets a list of persistent objects from database or other persistent source 
		/// </summary>
		/// <param name="query">Query to use, could be a query(NHibernate) or a statement name(IBatis)</param>
		/// <returns>A list of found object</returns>
		IList<T> FindList<T>(String query);

		/// <summary>
		/// Gets a list of persistent objects from database or other persistent source. The
		/// list will be paginated
		/// </summary>
		/// <param name="query">Query to use, could be a query(NHibernate) or a statement name(IBatis)</param>
		/// <param name="parameters">The parameters to use</param>
		/// <param name="pageIndex">page index to get</param>
		/// <param name="pageSize">size of page</param>
		/// <returns>A list of found object</returns>
		IList<T> FindList<T>(String query,Object parameters,int pageIndex,int pageSize);

		/// <summary>
		/// Deletes an object from database or other persistent source.
		/// </summary>
		/// <param name="query">Query to use, could be a query(Hibernate) or a statement name(IBatis)</param>
		/// <param name="o">object to delete</param>
		void Delete(String query,Object o);

		/// <summary>
		/// Updates an object from database or other persistent source.
		/// </summary>
		/// <param name="query">Query to use, could be a query(Hibernate) or a statement name(IBatis)</param>
		/// <param name="o">object to update</param>
		void Update(String query,Object o);

		/// <summary>
		/// Inserts an object from database or other persistent source.
		/// </summary>
		/// <param name="query">Query to use, could be a query(NHibernate) or a statement name(IBatis)</param>
		/// <param name="o">object to insert</param>
		void Insert(String query,Object o);
	}
}
